package bean;

import java.util.HashMap;
import java.util.Map;

public class Message {
//    状态码
    private int statusCode;
//    提示信息
    private String msg;

//    用户要返回给浏览器的数据
    private Map<String, Object> extendedData = new HashMap<>();

    public static  Message success() {
        Message message = new Message(200, "处理成功");
        return message;
    }

    public static  Message failure() {
        Message message = new Message(-1, "处理失败");
        return message;
    }

    public Message addData(String key, Object value) {
        this.getExtendedData().put(key, value);
        return this;
    }

    public Message(int statusCode, String msg, Map<String, Object> extendedData) {
        this.statusCode = statusCode;
        this.msg = msg;
        this.extendedData = extendedData;
    }

    public Message(int statusCode, String msg) {
        this.statusCode = statusCode;
        this.msg = msg;
    }

    public Message() {
    }

    public int getStatusCode() {
        return statusCode;
    }

    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Map<String, Object> getExtendedData() {
        return extendedData;
    }

    public void setExtendedData(Map<String, Object> extendedData) {
        this.extendedData = extendedData;
    }
}
